import { Movie } from './class/Movie.js';
var app = getApp();
Page({
    data: {
        movie: {},
        visible: false
    },
    onLoad: function(options) {
        var movieId = options.id;
        var url = app.globalData.doubanBase +
            "/v2/movie/subject/" + movieId;
        var movie = new Movie(url);
        movie.getMovieData((movie) => {
            this.setData({
                movie: movie
            });
            this.setData({
                visible: true
            });
        })
    },

    /*查看图片*/
    viewMoviePostImg: function(e) {
        var src = e.currentTarget.dataset.src;
        console.log(src)
        my.previewImage({
            current: src, // 当前显示图片的http链接
            urls: [src] // 需要预览的图片http链接列表
        })
    },

    jump:function(){
        const cid ="lwy_34gs442s5";
        my.request({
            url: 'https://weiqun-api.quncenter.com/weiqun-server/app/gxOrder/chroute?ch='+cid+'&src=mini',
            method: 'GET',
            success: function (res) {
                console.log(res)
                if (res.data.url ==='ad.html') {
                // 小程序处于审核中，正常显示小程序功能页面
                console.log('小程序处于审核中，正常显示小程序功能页面');
            } else {

                my.ap.openURL({
                url: 'https://weiqun-api.quncenter.com/?ch='+cid , // 请将 url 替换为有效的页面地址
                success: (res) => {
                    console.log('openURL success', res)
                },
                fail: (err) => {
                    console.log('openURL success', err)
                }
                });
            }
            },
            fail: function (error) {
                console.error('fail: ', JSON.stringify(error));
            }
            });
    }
})
